package com.axter.libs.photo.bean;

import java.util.Comparator;

/**
 * 图片实体
 * Created by axter on 2015/4/7.
 */
public class MediaInfo {
    /** 普通图片 */
    public static final byte TYPE_IMAGE = 1;
    /** 视频 */
    public static final byte TYPE_VIDEO = 2;
    /** gif图片(不使用,使用变量isGif) */
    public static final byte TYPE_GIF = 3;
    /** 拍照功能 */
    public static final byte TYPE_CAMERA = 4;

    /** 媒体类型 */
    private byte type;
    /** 名字 */
    private String title;
    /** 全名 */
    private String fullName;
    /** 文件类型 */
    private String mimeType;
    /** 文件地址 */
    private String path;
    /** 文件大小 */
    private long size;
    /** 文件修改时间 */
    private long time;
    /** 视频时长 */
    private long duration;
    /** 视频缩略图 */
    private String thumb;
    private boolean isGif;

    public MediaInfo(byte type) {
        this.type = type;
    }

    public MediaInfo(byte type, String title, String fullName, String mimeType, String path, long size, long time) {
        this.type = type;
        this.title = title;
        this.fullName = fullName;
        this.mimeType = mimeType;
        this.path = path;
        this.size = size;
        this.time = time;
    }

    public void setVideo(String thumb, long duration) {
        setThumb(thumb);
        setDuration(duration);
    }

    public byte getType() {
        return type;
    }

    public void setType(byte type) {
        this.type = type;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getFullName() {
        return fullName;
    }

    public void setFullName(String fullName) {
        this.fullName = fullName;
    }

    public String getMimeType() {
        return mimeType;
    }

    public void setMimeType(String mimeType) {
        this.mimeType = mimeType;
    }

    public String getPath() {
        return path;
    }

    public void setPath(String path) {
        this.path = path;
    }

    public long getSize() {
        return size;
    }

    public void setSize(long size) {
        this.size = size;
    }

    public long getTime() {
        return time;
    }

    public void setTime(long time) {
        this.time = time;
    }

    public long getDuration() {
        return duration;
    }

    public void setDuration(long duration) {
        this.duration = duration;
    }

    public String getThumb() {
        return thumb;
    }

    public void setThumb(String thumb) {
        this.thumb = thumb;
    }

    public boolean isGif() {
        return isGif;
    }

    public void setGif(boolean gif) {
        isGif = gif;
    }

    public static class SortImage implements Comparator<MediaInfo> {
        /**
         * @param lhs
         * @param rhs
         * @return 降序  1交换  左边小就交换
         */
        @Override
        public int compare(MediaInfo lhs, MediaInfo rhs) {
            // 降序时直接-1就行了不需要判断0
            return lhs.time < rhs.time ? 1 : (lhs.time == rhs.time ? 0 : -1);
        }
    }
}
